//
//  DeliveryConfirmFooterView.m
//  HAODE
//
//  Created by panquanReabam.com on 16/5/30.
//  Copyright © 2016年 reabam.com. All rights reserved.
//

#import "DeliveryConfirmFooterView.h"

@interface DeliveryConfirmFooterView()<UITextFieldDelegate,UITextViewDelegate>
@end

@implementation DeliveryConfirmFooterView
{

    UIImageView*images;
    UILabel*label;
}
@synthesize mDelegate;


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
        
        
        UIView*footview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 300)];
        [self addSubview:footview];
        UIView* huiview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
        huiview.backgroundColor=zuiqianhuiColor;
        huiview.layer.borderColor = qianhuiColor.CGColor;
        [huiview.layer setBorderWidth:0.35];   //边
        [footview addSubview:huiview];
        UILabel* type=[[UILabel alloc]initWithFrame:CGRectMake(15, 10, 80, 50)];
        type.text=[NSString stringWithFormat:@"物流商"];
        type.textColor=shenhuiColor;
        type.font=[UIFont systemFontOfSize:15];
        [footview addSubview:type];
        
        _expressCompanyTextFied=[[UITextField alloc]initWithFrame:CGRectMake(type.right,10, ScreenWidth*300/750,50)];
        _expressCompanyTextFied.borderStyle = UITextBorderStyleNone;
        _expressCompanyTextFied.keyboardType = UIKeyboardTypeDecimalPad;
        _expressCompanyTextFied.font = [UIFont systemFontOfSize: 15];
        _expressCompanyTextFied.textColor=[UIColor blackColor];
        _expressCompanyTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
        _expressCompanyTextFied.tag=6;
        _expressCompanyTextFied.placeholder = @"请选择物流商"; //默认显示的字
        _expressCompanyTextFied.delegate = self;
        [_expressCompanyTextFied setUserInteractionEnabled:NO];
        _expressCompanyTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
        [footview addSubview:_expressCompanyTextFied];
        UIButton*jiant = [[UIButton alloc] initWithFrame:CGRectMake(90,10,ScreenWidth, 50)];
        [jiant addTarget:self action:@selector(ExpressCompany:) forControlEvents:UIControlEventTouchUpInside];
        [footview addSubview:jiant];
        UIButton*jiantouBtn12 = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-30,27.5,8, 13)];
        [jiantouBtn12 setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
        [jiantouBtn12 addTarget:self action:@selector(ExpressCompany:) forControlEvents:UIControlEventTouchUpInside];
        [footview addSubview:jiantouBtn12];
        
        UILabel *lineLabel11=[[UILabel alloc] initWithFrame:CGRectMake(15, 50+10, ScreenWidth-30, 0.35)];
        lineLabel11.backgroundColor=qianhuiColor;
        [footview addSubview:lineLabel11];
        
        UILabel* NoLabel=[[UILabel alloc]initWithFrame:CGRectMake(15, lineLabel11.bottom, 80, 50)];
        NoLabel.text=[NSString stringWithFormat:@"物流单号"];
        NoLabel.textColor=shenhuiColor;
        NoLabel.font=[UIFont systemFontOfSize:15];
        [footview addSubview:NoLabel];
        _expressNumberTextFied=[[UITextField alloc]initWithFrame:CGRectMake(NoLabel.right,lineLabel11.bottom, ScreenWidth*300/750,50)];
        _expressNumberTextFied.borderStyle = UITextBorderStyleNone;
        _expressNumberTextFied.keyboardType = UIKeyboardTypeDecimalPad;
        _expressNumberTextFied.font = [UIFont systemFontOfSize: 15];
        _expressNumberTextFied.textColor=[UIColor blackColor];
        _expressNumberTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
        _expressNumberTextFied.tag=6;
        _expressNumberTextFied.placeholder = @"请输入物流单号"; //默认显示的字
        _expressNumberTextFied.delegate = self;
        [_expressNumberTextFied setUserInteractionEnabled:YES];
        _expressNumberTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
        [footview addSubview:_expressNumberTextFied];
        UIView* huiviewview2=[[UIView alloc]initWithFrame:CGRectMake(0, _expressNumberTextFied.bottom, ScreenWidth, 10)];
        huiviewview2.backgroundColor=zuiqianhuiColor;
        huiviewview2.layer.borderColor = qianhuiColor.CGColor;
        [huiviewview2.layer setBorderWidth:0.35];   //边
        [footview addSubview:huiviewview2];
        
        UIView* myToolBar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, viewheight)];
        myToolBar.backgroundColor=jianpancolor;
        UIButton*  tubtnDone=[[UIButton alloc]initWithFrame:CGRectMake(logoX,logoY, logoheight, logowidth)];
        [tubtnDone setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        [tubtnDone addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
        [myToolBar addSubview:tubtnDone];
        UIButton*btnDone111=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width - 55, 12, 40, 16)];
        [btnDone111 setTitle:@"确定" forState:UIControlStateNormal];
        [btnDone111 setTitleColor:jianpancolor1 forState:UIControlStateNormal];
        btnDone111 .titleLabel .font=[UIFont systemFontOfSize:keyboardFot];
        [btnDone111 addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
        [myToolBar addSubview:btnDone111];
        myToolBar.alpha=alp;
        UIButton* dabtn=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width-60, 0, 60, 40)];
        [dabtn addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
        [myToolBar addSubview:dabtn];
        
        
        _describeView=[[UITextView alloc]init];
        _describeView.frame=CGRectMake(15, huiviewview2.bottom+10, ScreenWidth-30, ScreenHeight*185/1334);
        _describeView.backgroundColor = [UIColor whiteColor];//设置它的背景颜色/Users/jiezsoft/Desktop/
        _describeView.scrollEnabled = YES;//是否可以拖动
        _describeView.delegate=self;
        _describeView.font = [UIFont fontWithName:@"Arial" size:15.0];//设置字体名字和字体大小
        _describeView.layer.borderWidth =0;
        CGColorSpaceRef registedSpace11 = CGColorSpaceCreateDeviceRGB();
        CGColorRef tureBTncolorref111 = CGColorCreate(registedSpace11,(CGFloat[]){ 0, 0, 0, 0.3 });
        [_describeView.layer setBorderColor:tureBTncolorref111];//边框颜色
        _describeView.layer.cornerRadius =0;
        [footview addSubview:_describeView];
        images=[[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 20, 15)];
        images.image=[UIImage imageNamed:@"_0000_xingxifankui.png"];
        [_describeView addSubview:images];
        label=[[UILabel alloc]init];
        label.frame =CGRectMake(30, 5, ScreenWidth-60, 15);
        label.text = @"描述";
        label.textColor=zuiqianhuiColor;
        label.numberOfLines=0;
        label.font=[UIFont systemFontOfSize:15];
        label.enabled = NO;//lable必须设置为不可用
        label.backgroundColor = [UIColor clearColor];
        [_describeView addSubview:label];
        _expressNumberTextFied.inputAccessoryView = myToolBar;
        _describeView.inputAccessoryView = myToolBar;


    }
    return self;
}

-(void)textViewDidChange:(UITextView *)textView
{
    
    if (textView.text.length == 0) {
        [images removeFromSuperview];
        images=[[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 51/3, 51/3)];
        images.image=[UIImage imageNamed:@"_0000_xingxifankui.png"];
        [_describeView addSubview:images];
        label.text = @"描述";
        
    }else{
        [images removeFromSuperview];
        label.text = @"";
    }
}
- (void)textFieldDidBeginEditing:(UITextField *)textField{
if (textField.tag == 6)
    {
    [mDelegate BeginEditing:@""];
    }
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    
     [mDelegate BeginEditing:@""];
    return self;
}
-(void)OnTapDone{
    [mDelegate OnTapDone:@""];
    [_expressNumberTextFied resignFirstResponder];
    [_describeView resignFirstResponder];
    
}
-(void)store{
    
   
    
}
-(void)ExpressCompany:(UIButton*)sender{
    
    [mDelegate ExpressCompany:@""];
}
@end
